#!/usr/bin/perl

# $Id: 16_host.t 242 2010-07-13 11:23:09Z dolbanavt $
# $Date: 2010-07-13 14:23:17 +0300 (Вто, 13 Июл 2010) $
# $HeadURL: https://robosearch.googlecode.com/svn/branches/reborn/t/16_host.t $
# $LastChangedRevision: 349 $

use FindBin qw( $RealBin );
use File::Spec::Functions qw( catfile );

BEGIN {
    push @INC, catfile( $RealBin, '..', 'base_lib' );
    push @INC, catfile( $RealBin, '..', 'lib' );
}

use JIP::ToolSet;
use English qw( -no_match_vars );
use Test::More 0.88;
use Const::Fast qw( const );
use Test::MockObject;
use Test::Exception;

const my $MODULE => 'Host';

use_ok $MODULE;
require_ok $MODULE;

can_ok $MODULE, qw(
    new _init
    get_id get_ip_address
    set_id set_ip_address
);

throws_ok { $MODULE->new(); }
    qr{^Required\soption\s'host_id'\sis\snot\sprovided}xms,
    'new( host_id )';

throws_ok { $MODULE->new( host_id => q{} ); }
    qr{^Required\soption\s'ip_address'\sis\snot\sprovided}xms,
    'new( ip_address )';

my $o = $MODULE->new( host_id => 42, ip_address => '10.0.14.140' );

ok $o, 'got object';

isa_ok $o, $MODULE;
isa_ok $o, 'JIP::BaseClass';
isa_ok $o, 'Class::Accessor::Fast';

is $o->get_id,         42,            'id accessor';
is $o->get_ip_address, '10.0.14.140', 'ip_ddress accessor';

done_testing();
